package com.nineclock.doc.service.imp;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.nineclock.common.enums.ResponseEnum;
import com.nineclock.common.exception.NcException;
import com.nineclock.doc.mapper.SysBanMapper;
import com.nineclock.doc.pojo.DocFile;
import com.nineclock.doc.service.BanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class SysBan implements BanService {
    @Autowired
    private SysBanMapper smsBanMapper;

    @Override
    public void Ban(Long fileId, Short status) {
        //健壮性判断
        if (fileId==null||status==null){
            throw new NcException(ResponseEnum.INVALID_PARAM_ERROR);
        }
        //设置要更新的条件
        LambdaUpdateWrapper<DocFile> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(DocFile::getId,fileId);
        //更新字段
        DocFile docFile = new DocFile();
        docFile.setStatus(status);
        smsBanMapper.update(docFile,wrapper);
    }

}
